import request from '@/router/axios'

export const getDeptTree = (tenantId) => {
  return request({
    url: '/api/blade-system/dept/tree',
    method: 'get',
    params: {
      tenantId,
    }
  })
}

export const getfileByTaskId = (params) => {
  return request({
    url: '/api/apqpfiletmpl/list',
    method: 'get',
    params
  })
}

export const submitBatch = (data) => {
  return request({
    url: '/api/apqpfiletmpl/submitBatch',
    method: 'post',
    data
  })
}

export const remove = (ids) => {
  return request({
    url: '/api/apqpfiletmpl/remove',
    method: 'post',
    params: {
      ids
    }
  })
}

export const getfilesList = (params) => {
  return request({
    url: '/api/attach/attachList',
    method: 'post',
    params
  })
}

export const removeFile = (params) => {
  return request({
    url: '/api/attach/deleteAttachs',
    method: 'post',
    params: {
      ...params
    }
  })
}


// 文档清单-列表
export const docList = (current, size, params) => {
  return request({
    url: '/api/apqpfiletmpl/page',
    method: 'get',
    params: {
      current,
      size,
      ...params,
    }
  })
}

// 文档清单-列表不分页
export const documentList = (params) => {
  return request({
    url: '/api/apqpfiletmpl/list',
    method: 'get',
    params
  })
}

// 文档清单-保存
export const docSave = (data) => {
  return request({
    url: '/api/apqpfiletmpl/save',
    method: 'post',
    data
  })
}

// 文档清单-修改
export const docUpdate = (data) => {
  return request({
    url: '/api/apqpfiletmpl/update',
    method: 'post',
    data
  })
}

// 文档清单-删除
export const docRemove = (ids) => {
  return request({
    url: '/api/apqpfiletmpl/remove',
    method: 'post',
    params: {
      ids
    }
  })
}

// 任务文档
// 查询关联文件
export const fileList = (params) => {
  return request({
    url: '/api/phasestaskfile/list',
    method: 'get',
    params
  })
}

// 关联任务文件
export const connectFile = (data) => {
  return request({
    url: '/api/phasestaskfile/submitBatch',
    method: 'post',
    data
  })
}

// 删除关联任务文件
export const removeConnectFile = (ids) => {
  return request({
    url: '/api/phasestaskfile/remove',
    method: 'post',
    params: {
      ids
    }
  })
}
